﻿<!DOCTYPE html>

<html>

<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    @Scripts.Render("~/Resource/js/fe.head.js")
</head>

<body>
    <div id="app" v-cloak>
        <div class="edit_pagecontainer">
            <div class="edit_formcontainer">
                <el-form ref="form" :model="form" :label-width="labelWidth" :rules="rules">
                    <el-form-item label="原密码" prop="PassWord">
                        <el-input v-model="form.PassWord" show-password prefix-icon="el-icon-camera-solid"></el-input>
                    </el-form-item>
                    <el-form-item label="新密码" prop="NewPassWord">
                        <el-input v-model="form.NewPassWord" show-password prefix-icon="el-icon-camera-solid">
                        </el-input>
                    </el-form-item>
                    <el-form-item label="确认密码" prop="ConfirmPassWord">
                        <el-input v-model="form.ConfirmPassWord" show-password prefix-icon="el-icon-camera-solid">
                        </el-input>
                    </el-form-item>
                </el-form>
            </div>
        </div>
        <div class="edit_opcontainer">
            <el-button type="primary" v-on:click="handleSubmit">保 存</el-button>
            <el-button v-on:click="close">取 消</el-button>
        </div>
    </div>
</body>
@Scripts.Render("~/Resource/js/fe.foot.js")
<script>
    var updateUrl = GetRootPath() + "Frame/User/OperateModifyPWD";
    var pageData = {
        //data
        form: {
            PassWord: '',
            NewPassWord: '',
            ConfirmPassWord: ''
        },

        //rules
        rules: {
            PassWord: [{
                required: true,
                message: '请输入原密码',
                trigger: 'blur'
            }, ],
            NewPassWord: [{
                required: true,
                message: '请输入新密码',
                trigger: 'blur'
            }, ],
            ConfirmPassWord: [{
                required: true,
                message: '请输入确认密码',
                trigger: 'blur'
            }, ],
        },
        //css
        labelWidth: '100px'
    };

    new Vue({
        el: '#app',
        data: pageData,
        mounted: function () {

        },
        methods: {
            handleSubmit: function () {
                this.$refs["form"].validate((valid) => {
                    if (valid) {
                        if (pageData.form.NewPassWord == pageData.form.ConfirmPassWord) {
                            JsonAjaxPost(updateUrl, JSON.stringify(pageData.form), function (data,
                                status) {
                                if (data.code == 0) {
                                    OpenSuccess('提示', '保存成功！', function () {
                                        CloseDialog();
                                    })
                                } else {
                                    OpenFail('提示', data.msg)
                                }
                            })
                        } else {
                            OpenWaring('提示', '新密码两次不一致！')
                        }
                    }
                });
            },
            close: function () {
                CloseDialog();
            },

        }
    })
</script>

</html>
